package net.zwet.clanworks.resthome.services.info;

import net.zwet.clanworks.resthome.GenericService;
import net.zwet.clanworks.resthome.responses.InfoResponse;
import net.zwet.clanworks.common.enumerations.Status;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;


/**
 * Created with IntelliJ IDEA.
 * User: Hansz
 * Date: 6/12/13
 * Time: 12:58 AM
 * To change this template use File | Settings | File Templates.
 */

//Sets the path to base URL + /status
@Path("/api/info")
public class InfoService extends GenericService {

    // This method is called if TEXT_PLAIN is request
    @GET
    @Consumes(MediaType.TEXT_PLAIN)
    @Produces(MediaType.TEXT_PLAIN)
    public String infoPlainText() {
        return "Clanworks InfoResponse : status " + Status.OK.getCode();
    }

    // This method is called if HTML is request
    @GET
    @Consumes(MediaType.TEXT_HTML)
    @Produces(MediaType.TEXT_HTML)
    public String infoHtml() {
        return "<html> " + "<title>" + "Clanworks InfoResponse :" + "</title>"
                + "<body><h1>" + "Status code :" + Status.OK.getCode() + "</h1></body>" + "</html> ";
    }

    @GET
    @Produces({
            MediaType.APPLICATION_XML,
            MediaType.APPLICATION_JSON
    })
    public InfoResponse infoXmlJson () {
        InfoResponse info = new InfoResponse();

        info.setCode(Status.OK.getCode());
        info.setMessage(Status.OK.getDescription());

        return info;
    }
}
